% 将图像数据集中的数张图片整合到一张显示
% e.g. pos1.png ~ pos500.png , 128x64 per image
% 500张图片，分10行，每行50张


clc;
clear all;
close all;
 
totalImage = ones(128*10,64*50);    % 存放合并图片的矩阵
for i = 1:10
    for j = 1:50
        picPath = sprintf('pos/pos%d.png',(i-1)*10+j);
        pic = rgb2gray(imread(picPath));    % 只需灰度图
        %
        totalImage((1+(i-1)*128):(i*128),(1+(j-1)*64):(j*64)) = pic;    % 矩阵赋值
    end
end
totalImage = totalImage./255;    % 归一化
imwrite(totalImage,'showPos.png');
figure
imshow(totalImage);

for i = 1:10
    for j = 1:50
        picPath = sprintf('neg/neg%d.png',(i-1)*10+j);
        pic = rgb2gray(imread(picPath));
        %
        totalImage((1+(i-1)*128):(i*128),(1+(j-1)*64):(j*64)) = pic;  
    end
end
totalImage = totalImage./255;
imwrite(totalImage,'showNeg.png');
figure
imshow(totalImage);